package com.apes.autoparts.product.repository;

import com.apes.autoparts.product.model.AccumulatorProduct;
import com.apes.autoparts.product.model.OilyProduct;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 类描述：
 *
 * @ClassName TyreProductRepository
 * @Description 描述
 * @Author lilong
 * @Date 2022/10/26 10:23
 * @Version 1.0
 */
public interface AccumulatorProductRepository extends CustomRepository<AccumulatorProduct, String> {

    @Query(value = "SELECT a.* from auto_accumulator_product a , (SELECT max(id) as id from auto_accumulator_product \n" +
            "group by brand, grade, reference) b where a.id = b.id", nativeQuery = true)
    List<AccumulatorProduct> findAllByStandard();


    @Query(value = "select a.id as id from AccumulatorProduct a")
    Set<String> findAllId();

    AccumulatorProduct findByBrandAndGradeAndReference(String brand, String grade, String reference);//慢的话，加索引
}
